Trigonometry curves (sin, cos and tan)
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.drawing.xaxis.js"></script>
<script src="RGraph.scteter.js"></script>
Put this where you want the chart to show up:
<canvas id="cvs" width="1000" height="200">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
var data_sin = [],
data_cos = [],
data_tan = [];
for (var i=-360; i<360; i+=1) {
data_sin.push([i, Math.sin(i / (180 / Math.PI))]);
data_cos.push([i, Math.cos(i / (180 / Math.PI))]);
var tan_value = Math.tan(i / (180 / Math.PI));
data_tan.push([i, (tan_value < 1 && tan_value > -1) ? tan_value : null]);
}
var xaxis = new RGraph.Drawing.XAxis({
id: 'cvs',
y:100,
options: {
scaleZerostart: false,
yaxispos: 'center',
numlabels: 4,
numticks: 16,
max: 360,
textAccessible: true
}
}).draw()
var scatter = new RGraph.Scatter({
id: 'cvs',
data: [data_sin, data_cos, data_tan],
options: {
ymax: 1,
xmax: 360,
scaleDecimals: 1,
gutterLeft: 500,
line: true,
lineLinewidth: 3,
tickmarks: null,
xaxispos: 'center',
xaxis: false,
backgroundGrid: false,
outofbounds: false,
textAccessible: true
}
}).trace2();
</script>